#pragma once

#include "DAL.h"

typedef enum {CACHE_NOT_FOUND, CACHE_SIMPLE, CACHE_CREATE, CACHE_DELETE} CacheType;

typedef struct
{
	CacheType CacheType;
	DataEntity DataEntity;
} CacheEntity;

//DALCache.c
int CreateEntityCaches();
void DestructEntityCaches();

int CreateOrEditEntityInCache(unsigned int EntityTypeIndex, unsigned int ID, DataEntity DEntity);

//This function should only be called when the entity didn't exist in the cache before and was loaded from a file (so that its CacheType would be CACHE_SIMPLE
//If the entity was already found, the function will do nothing and return 1 (it would normally return 0)
int SetEntityInCache(unsigned int EntityTypeIndex, unsigned int ID, DataEntity DEntity);

/*
	Return values:
	1: one of the following:
		a. entity not found in cache but marked for delete nonetheless, b. entity in cache found and marked for delete.
	0: entity in cache is already marked for delete.
*/
int DeleteEntityInCache(unsigned int EntityTypeIndex, unsigned int ID);

CacheEntity GetEntityInCache(unsigned int EntityTypeIndex, unsigned int ID);